# coding: utf-8

import time


def now_sec():
    return int(time.time())

# 时间戳 -> 字符串  格式输出为YYYY-MM-DD HH:MI:SS
def formatDateTime(Timestamp):
    return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(Timestamp))


# 时间戳 -> 字符串  格式输出为YYYY-MM-DD
def formatDate(Timestamp):
    return time.strftime("%Y-%m-%d", time.localtime(Timestamp))


# 时间戳 -> 字符串 输出格式由入参format指定
def formatTimeWithDesc(Timestamp, format):
    return time.strftime(format, time.localtime(Timestamp))


# 字符串 -> 时间戳 字符串格式为YYYYMMDD
def formatDatestamp(Datetime):
    return int(time.mktime(time.strptime(Datetime, "%Y-%m-%d")))


# 字符串 -> 时间戳 字符串格式为YYYY-MM-DD HH:MI:SS
def formatTimestamp(Datetime):
    return int(time.mktime(time.strptime(Datetime, "%Y-%m-%d %H:%M:%S")))




def start(start_time):
    """开始时间，当天0点"""

    return formatDatestamp(start_time)


def end(end_time):
    """结束时间，下一天0点"""

    return formatDatestamp(end_time) + 86400
